package cate.game.role.farm.island.po;

import cate.game.GameBody;
import cate.game.role.farm.island.cell.IslandCell;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

import java.util.ArrayList;
import java.util.List;

@NoteClass(value = "迷宫中的一关")
public class IslandLevel {

    @NoteField(value = "第几关")
    public int level;

    @NoteField(value = "这一关中的格子")
    public List<IslandCell> cells;

    public void initialize(GameBody game) {
        if (cells == null) {
            cells = new ArrayList<>();
        }
        cells.forEach(a -> a.initialize(game));
    }

    public void addCell(IslandCell cell) {
        cells.add(cell);
    }

    public IslandCell getCell(int x) {
        for (IslandCell cell : cells) {
            if (cell.x == x) {
                return cell;
            }
        }
        return null;
    }

    public void clear() {
        cells.clear();
    }
}
